﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using iLangl.Security;
using System.Web.Security;

namespace iLangl.Tests.SecurityFixture
{
	[TestClass]
	public class SessionFixture
	{
		[TestMethod]
		public void SessionTest()
		{
			String username = "sergey.yuryev" + Guid.NewGuid().ToString() + "@gmail.com";
			String password = "test";

			CustomerAuthenticationService service = new CustomerAuthenticationService();
			String result = service.RegisterUser(username, password);
			Assert.AreEqual(result, MembershipCreateStatus.Success.ToString());

			String session =  service.CreateSession(username, password);
			Assert.IsFalse(String.IsNullOrEmpty(session));

			Assert.IsTrue(service.IsAuthenticated(session));

			Assert.IsFalse(service.IsAuthenticated(Guid.NewGuid().ToString()));


			string resultUserName = service.GetUserName(session);
			Assert.AreEqual(resultUserName, username);

		}
	}
}
